userlist = ['张斯', '胡倩云']
user_score = [99, 100]

for user in userlist:
    if user == '胡倩云':
        i = userlist.index(user)
        print(user_score[i])


##### 字典的定义
# 使用`{}`定义，包含key, value
# 每个元素之间用`,`分隔
# key,value用`:`

user_score = {'张斯':99, '胡倩云':100}
print(user_score['张斯'])

# dict = > 字典
# key->value  键值对
singer_song = {"李圣杰": '痴心绝对', '张韶涵': '阿刁', '汪峰':'普通迪斯高'}
print(singer_song)
singer_null = {}
print(singer_null)
singer_null = dict()
print(singer_null)

### key和value的取值问题
# value 可以是任意数据
singer_song = {"李圣杰": '痴心绝对', '张韶涵': ('阿刁','隐形的翅膀'), '汪峰':['普通迪斯高', '北京北京']}
print(singer_song)
# key只能是能hash的数据（hash_map）
# 不可变对象才能作为key
# list是可变对象
# TypeError: unhashable type: 'list'
# singer_song = {None:None, (1,2,3):None, True:None , [1,2,3]:None ,"李圣杰": '痴心绝对', '张韶涵': ('阿刁','隐形的翅膀'), '汪峰':['普通迪斯高', '北京北京']}
singer_song = {None:None, (1,2,3):None, True:None ,"李圣杰": '痴心绝对', '张韶涵': ('阿刁','隐形的翅膀'), '汪峰':['普通迪斯高', '北京北京']}
print(singer_song)

# 重复定义时：key不可重复
singer_song = {"李圣杰": '痴心绝对', '张韶涵': '阿刁', '汪峰':'普通迪斯高', '汪峰':'当我想你的时候'}
print(singer_song)


### 查
singer_song = {None:None, (1,2,3):None, True:None ,"李圣杰": '痴心绝对', '张韶涵': ('阿刁','隐形的翅膀'), '汪峰':['普通迪斯高', '北京北京']}
print(singer_song['张韶涵'])
# # KeyError: '张韶涵1': key不存在时会报错
# print(singer_song['张韶涵1'])

print(singer_song.get('张韶涵','no song'))
print(singer_song.get('张韶涵1','no song'))
print(singer_song.get('张韶涵1'))

print(singer_song.keys())
print(singer_song.values())
print(singer_song.items())

for item in singer_song.items():
    print(item)


#### 修改和增加
singer_song = {None:None, (1,2,3):None, True:None ,"李圣杰": '痴心绝对', '张韶涵': ('阿刁','隐形的翅膀'), '汪峰':['普通迪斯高', '北京北京']}
singer_song[True] = 'I Am True'
print(singer_song)
singer_song["林"] = '林志炫'
print(singer_song)

## 字典合并
singer_song2 = {'a':'a','b':'b'}
#对自身操作
singer_song.update(singer_song2)
print(singer_song)
# # TypeError: unsupported operand type(s) for +: 'dict' and 'dict'
# print(singer_song+singer_song2)
print(dict(singer_song, **singer_song2))


### 成员关系
singer_song1 = {"李圣杰": '痴心绝对', '张韶涵': '阿刁'}
print("李圣杰1" in singer_song1)
print('当我想你的时候' not in  singer_song1.values())
print(singer_song1.has_key("李圣杰1"))


